package com.taxi.daos.mysql;

import java.io.IOException;
import java.io.Reader; 
import java.util.ArrayList;
import java.util.List;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder; 
import com.taxi.bean.VehiculoBean;
import com.taxi.daos.interfaces.VehiculoDAO;
import com.taxi.util.UtilSqlConfig;

public class VehiculoDAOImpl implements VehiculoDAO {

	SqlMapClient sqlMap = UtilSqlConfig.getSqlMapInstance();
	
	public void registrarVehiculo(VehiculoBean bean) throws Exception {
		VehiculoBean vehiculo = (VehiculoBean)sqlMap.insert("registrarVehiculo",bean);
		System.out.println("Entro");
	}
	
	public VehiculoBean codigoAutogenerado() throws Exception {
		// TODO Auto-generated method stub
		return (VehiculoBean)sqlMap.queryForObject("obtenerAutogeneradoVehiculo");
	}
	 
	public void actualizarVehiculo(VehiculoBean bean) throws Exception {
		 sqlMap.update("actualizarVehiculo",bean);
	}
	 
	public void eliminarVehiculo(VehiculoBean bean) throws Exception {
		  sqlMap.delete("eliminarVehiculo",bean);
	}

	@SuppressWarnings("unchecked")
	public List<VehiculoBean> listadoVehiculo() throws Exception {
		
		return (List<VehiculoBean>)sqlMap.queryForList("listadoVehiculo");
		
	}
	
	 
	public ArrayList<VehiculoBean> listaVehiculo() throws Exception {
		// TODO Auto-generated method stub
		return (ArrayList<VehiculoBean>)sqlMap.queryForList("listarVehiculo");
	}
	 
	public VehiculoBean listarxrucVehiculo(String ruc) throws Exception {
		// TODO Auto-generated method stub
		return (VehiculoBean)sqlMap.queryForObject("listarxrucVehiculo", ruc);
	}
	 
	public List<VehiculoBean> listarVehiculosPorEmpresa(int id)
			throws Exception {
		// TODO Auto-generated method stub
		 return sqlMap.queryForList("listarPlacasPorEmpresa", id);
	}
	
}
